<template>
	<view class="product-box">
		<view class="product-item" @click="onProductsItemTap(item.id)" v-for="item in data" :key="item._id">
			<u-image shape="circle" width="300" height="220" class="product-image" :src="item.url" mode="aspectFill">
				<u-loading slot="loading"></u-loading>
			</u-image>
			<view class="product-item-bottom">
				<text class="name">{{item.name}}</text>
				<view class="price">¥{{item.price}}</view>
			</view>
		</view>
	</view>
</template>

<script>
	// import { mapActions } from 'vuex';
	export default {
		name: "product-card",
		props: {
			data: {
				type: Array,
				default: function(){
					return []
				}
			},
		},
		data() {
			return {
				
			};
		},
		methods: {
			// ...mapActions('m_search',['set_history']),
			onProductsItemTap(id,name) {
				this.$emit("onProductsItemTap",id)
			},
			setHistory(name) {
				// this.setHistory({name})
				this.$emit('setHistory',name)
			}
		},
	}
</script>

<style lang="scss">
	page {
		width: 750rpx;
		height: 100vh;
	}

	.product-box {
		margin: 0 20rpx 20rpx 20rpx;
		display: flex;
		flex-wrap: wrap;
		justify-content: space-between;

		.product-item {
			min-height: 300rpx;
			width: 49%;
			border-radius: 10rpx;
			margin-right: 0;
			margin-bottom: 10rpx;
			background-color: #F5F6F5;
			text-align: center;
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: center;
			

			.product-image {
				// margin: 10rpx auto 0 auto;
				// width: 80%;
				// height: 220rpx;
				// border-radius: 10rpx;
			}

			.product-item-bottom {
				text-align: center;
				margin-bottom: 20rpx;
				color: #333;
			}

			.product-item-bottom .name {
				font-size: 28rpx;
			}

			.product-item-bottom .price {
				font-size: 24rpx;
			}
		}
	}
</style>
